package com.capgemini.remind.pojo;

import com.capgemini.remind.constant.CONST;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;


/**
 * Created by annson on 2016/7/3.
 */
public class HqPromotion implements Serializable {
    private Long id;
    private Long packageDefId;
    private String maintenanceType;
    private String promotionalContent;
    private Boolean isSelected;

    private Long periodOfValidity;
    private String timeUnit;

    private String createBy;
    private Date createDate;
    private String lastUpdateBy;
    private Date lastUpdateDate;


    private String packageName;

    private Long couponBatchId;
    private Long couponBatchLineId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getPackageDefId() {
        return packageDefId;
    }

    public void setPackageDefId(Long packageDefId) {
        this.packageDefId = packageDefId;
    }

    public String getMaintenanceType() {
        return maintenanceType;
    }

    public void setMaintenanceType(String maintenanceType) {
        this.maintenanceType = maintenanceType;
    }

    public String getPromotionalContent() {
        return promotionalContent;
    }

    public void setPromotionalContent(String promotionalContent) {
        this.promotionalContent = promotionalContent;
    }

    public Boolean getIsSelected() {
        if(isSelected == null){
            isSelected = false;
        }
        return isSelected;
    }

    public void setIsSelected(Boolean isSelected) {
        this.isSelected = isSelected;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getLastUpdateBy() {
        return lastUpdateBy;
    }

    public void setLastUpdateBy(String lastUpdateBy) {
        this.lastUpdateBy = lastUpdateBy;
    }

    public Date getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(Date lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public Boolean getSelected() {
        return isSelected;
    }

    public void setSelected(Boolean selected) {
        isSelected = selected;
    }

    public Long getPeriodOfValidity() {
        return periodOfValidity;
    }

    public void setPeriodOfValidity(Long periodOfValidity) {
        this.periodOfValidity = periodOfValidity;
    }

    public String getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(String timeUnit) {
        this.timeUnit = timeUnit;
    }

    public Long getCouponBatchLineId() {
        return couponBatchLineId;
    }

    public void setCouponBatchLineId(Long couponBatchLineId) {
        this.couponBatchLineId = couponBatchLineId;
    }

    public Long getCouponBatchId() {
        return couponBatchId;
    }

    public void setCouponBatchId(Long couponBatchId) {
        this.couponBatchId = couponBatchId;
    }

    public String getSmsText(){
        StringBuilder text = new StringBuilder();

        text.append(promotionalContent);
        if(periodOfValidity != null && StringUtils.isNotBlank(timeUnit)){
            text.append("[收到短信后的").append(periodOfValidity).append(CONST.getTimeUnit(timeUnit)).append("内有效],");
        }

        return text.toString();
    }

    public String getSmsText(String couponNumber){
        StringBuilder text = new StringBuilder();

        text.append(promotionalContent);
        if(periodOfValidity != null && StringUtils.isNotBlank(timeUnit)){
            text.append("[优惠券:").append(couponNumber).append(", 收到短信后的").append(periodOfValidity).append(CONST.getTimeUnit(timeUnit)).append("内有效],");
        }

        return text.toString();
    }


}
